import mqtt from 'mqtt';

const client = mqtt.connect('wss://penglink.pcwxcn.top:8084/mqtt', {
  clientId: 'web-client-' + Math.random().toString(16).substr(2, 8),
  clean: true,
  reconnectPeriod: 1000,
  connectTimeout: 30 * 1000,
});

client.on('connect', () => {
  // console.log('MQTT connected');
});

client.on('error', (err) => {
  // console.error('MQTT error:', err);
});

client.on('close', () => {
  // console.log('MQTT disconnected');
});

export default client;
